package com.ls.socketio.repository;

import com.ls.socketio.bean.HotelInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @author liShan
 * @date 2019/9/3 16:20
 */
public interface HotelRepository extends JpaRepository<HotelInfo, Integer> {

    /**
     * 查询所有的酒店
     * @return 酒店
     */
    @Query(value = "SELECT * FROM hotel h LEFT JOIN build b USING(hotel_id) LEFT JOIN layer l USING(build_id) " +
            "ORDER BY hotel_id, build_num, layer_num", nativeQuery = true)
    List<HotelInfo> selectAll();

}
